<template>
	<view>
		
	</view>
</template>

<script>
	import {mapState, mapGetters, mapMutations, mapActions} from "vuex"
	
	export default {
		data() {
			return {
				
			}
		},
		
		onLoad() {
			//console.log(JSON.stringify(this.list))
			//console.log(JSON.stringify(this.newList))
			
			//直接调用getters
			//console.log(JSON.stringify(this.$store.getters.activeList))
			
			// //mapGetters
			// console.log(JSON.stringify(this.activeList))
			
			// //数量大于5 的
			// console.log('数量大于5的')
			// console.log(JSON.stringify(this.getList))
			
			// //查询ID为1的信息
			// console.log('只查询商品ID为1的信息')
			// console.log(JSON.stringify(this.getById(1)))
			
			// //mutations
			// console.log('测试增加方法')
			// this.$store.commit('inc')
			// this.inc()
			
			// console.log('测试增加方法带参数')
			// this.incByNum(10)
			
			// //调用异步actions
			// console.log('调用异步actions')
			// //this.$store.dispatch('AsyncInc')
			// this.AsyncInc(100)
			
			//分模块之后
			console.log(JSON.stringify(this.$store.state.cart.list))
			//调用方法
			console.log(JSON.stringify(this.getList))
		},
		
		computed: {
			
			//扩展运算符
			// ...mapState({
			// 	//list: state => state.list
				
			// 	//二：
			// 	//list: "list",
				
			// 	//三
			// 	// newList(state) {
			// 	// 	return state.list.filter(v => v.status)
			// 	// }
			// 	newList: state => state.list.filter(v => v.status)
			// })
			
			//第二种,用数组来拿
			// ...mapState(['list']),
			
			...mapGetters(['activeList', 'getList', 'getById'])
		},
		
		methods: {
			// ...mapMutations(['inc', 'incByNum']),
			
			// ...mapActions(['AsyncInc'])
		}
	}
</script>

<style>

</style>
